package pl.mcnova.model;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

public class HibernateSession {

	private AnnotationConfiguration configuration;
	private static SessionFactory factory = null;
	private static HibernateSession hibernateSession = null;

	private HibernateSession() {
		configuration = new AnnotationConfiguration().configure("/hibernate.cfg.xml");
		factory = configuration.buildSessionFactory();
	}

	public static SessionFactory getInstance() {
		if (hibernateSession== null) {
			hibernateSession = new HibernateSession();
		}
		return hibernateSession.getSession();
	}

	public SessionFactory getSession()
	{
		return factory;
	}
	
}
